﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Enterprise.Model.Article;
using Enterprise.Service.Article;
using Enterprise.Infrastructure;
using Enterprise.Service.User;
using Enterprise.Control;
using Enterprise.Service.Module;
namespace Enterprise.UI.Web.Modules.Article
{
    public partial class Index :Enterprise.Service.BasePage
    {
        protected int ModuleId = (int)Utility.sink("ModuleId", Utility.MethodType.Get, 0, 0, Utility.DataType.Int);
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                OnCommand();
                BindGrid();
            }
        }

        private void OnCommand()
        {
            string s=ModuleService.GetModuleName(ModuleId);
            CreateBT.AddButton("new.gif", "发布信息", "Edit.aspx?ModuleId=" + ModuleId, Utility.PopedomType.New, HeadMenu1);
            CreateBT.AddButton("list.gif", "信息查询", "Index.aspx?ModuleId=" + ModuleId, Utility.PopedomType.New, HeadMenu1);
            lb_MName.Text = s;
        }

        private void BindGrid()
        {
            ArticleService aService = new ArticleService();
            var list = aService.ArticleQianshouList(aService.ArticleList(ModuleId)).OrderByDescending(p => p.ACreateTime).ToList();
            GridView1.DataSource = list;
            GridView1.DataBind();
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            BindGrid();
        }

        public void Bt_Search_OnClick(object sender, EventArgs e)
        {
            string sType = (string)Utility.sink(s_Type.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Str);
            string sKey = (string)Utility.sink(s_Key.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Str);
            ArticleService aService = new ArticleService();
            var list = aService.ArticleQianshouList(aService.ArticleSearchList(sType, sKey)).OrderByDescending(p => p.ACreateTime).ToList();
            GridView1.DataSource = list;
            GridView1.DataBind();
        }


    }
}